package java111_2;

import java.util.Scanner;

public class Day35 {
    //https://www.nowcoder.com/practice/196141ecd6eb401da3111748d30e9141?tpld=128&tqld=33775&ru=/exam/oj
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            for (int i = 1; i <= 10; i++) {
                if ((1 << i) - 1 >= n) {
                    System.out.println((1 << (i - 1)) - 1);
                    break;
                }
            }
        }
    }

    //https://www.nowcoder.com/practice/11cc498832db489786f8a03c3b67d02c?tpId=182&tqId=34790&ru=/exam/oj



    //https://www.nowcoder.com/practice/3959837097c7413a961a135d7104c314?tpId=37&tqId=21275&ru=/exam/oj
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str1 = in.next(), str2 = in.next();
        int[][] dp = new int[str1.length()+1][str2.length()+1];
        // dp[i][j] 表示 字符串 str1 中的 (1, i) 位置 与 字符串 str2 中的 (1, j) 位置的编辑距离
        for(int i = 0; i <= str1.length(); i++){
            dp[i][0] = i;
        }
        for(int j = 0; j <= str2.length(); j++){
            dp[0][j] = j;
        }
        for(int i = 1; i <= str1.length(); i++){
            for(int j = 1; j <= str2.length(); j++){
                if(str1.charAt(i-1) == str2.charAt(j-1)){
                    dp[i][j] = dp[i-1][j-1];
                } else {
                    dp[i][j] = Math.min(dp[i-1][j], Math.min(dp[i-1][j-1], dp[i][j-1])) + 1;
                }
            }
        }
        System.out.println(dp[str1.length()][str2.length()]);
    }
}
